const toString = Object.prototype.toString
const checkVariableType = (type) => {
  return function isType(value) {
    return toString.call(value) === `[object ${type}]`
  }
}

export const isFn = checkVariableType('Function')
export const isUndefined = checkVariableType('Undefined')
export const isArray = checkVariableType('Array')
export const isString = checkVariableType('String')
export const isObject = checkVariableType('Object')
export const isNumber = checkVariableType('Number')
export const isDate = checkVariableType('Date')

export const isNull = (val) => val === null
export const isDefined = (val) => val !== undefined && !isNull(val)
export const isNaN = (val) => isNaN(val)